package com.atguigu.myjuc.mythread;

public class SyThread {

static class Ticket{
    int number=50;
    public synchronized void saleTicket(){
        if (number>0)
        System.out.println(Thread.currentThread().getName()+"当前有"+number--+"还剩下"+number);


    }
}




    public static void main(String[] args) throws InterruptedException {
        Ticket ticket = new Ticket();
       new Thread(() -> {for (int i = 0; i < 50; i++) ticket.saleTicket();},"A").start();

      new Thread(() -> {for (int i = 0; i < 50; i++) ticket.saleTicket();},"B").start();
         new Thread(() -> {for (int i = 0; i < 50; i++) ticket.saleTicket();},"C").start();




    }


}
